package com.example.afinal;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class ConfigActivity extends AppCompatActivity{

    EditText dollarEdit,euroEdit,wonEdit;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_config);

        Intent intent = getIntent();

        float dollar2 = intent.getFloatExtra("dollar_key",0f);
        float euro2 = intent.getFloatExtra("euro_key",0f);
        float won2 = intent.getFloatExtra("won_key",0f);

        dollarEdit = findViewById(R.id.dollar_rate);
        euroEdit = findViewById(R.id.euro_rate);
        wonEdit = findViewById(R.id.won_rate);

        dollarEdit.setText(String.valueOf(dollar2));
        euroEdit.setText(String.valueOf(euro2));
        wonEdit.setText(String.valueOf(won2));


    }

    public void save(View btn)
    {
        float new_dollar = Float.parseFloat(dollarEdit.getText().toString());
        float new_euro = Float.parseFloat(euroEdit.getText().toString());
        float new_won = Float.parseFloat(wonEdit.getText().toString());

        Intent retIntent = getIntent();
        Bundle bdl = new Bundle();
        bdl.putFloat("dollar_key2",new_dollar);
        bdl.putFloat("euro_key2",new_euro);
        bdl.putFloat("won_key2",new_won);
        retIntent.putExtras(bdl);
        setResult(2,retIntent);

        finish();
    }

}